package la.bbs558.entity.enums;

import la.bbs558.exception.MsgException;
import la.bbs558.util.Objs;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

@Getter
public enum UserMessageType {
    MSG_RELAY("回复我的", 1),
    MSG_SYS("系统消息", -1);
    //MSG_AT("@我的消息提醒", 3),
    //MSG_LIKE("受到赞的消息提醒", 4);

    private final String desc;
    private final Integer code;

    private final static List<UserMessageType> enums = Arrays.asList(values());

    UserMessageType(String desc, Integer code) {
        this.desc = desc;
        this.code = code;
    }

    public static UserMessageType getByName(String optType) {
        for (UserMessageType value : enums) {
            if (Objs.equal(value.name(), optType)) {
                return value;
            }
        }
        throw new MsgException("不存在此枚举");
    }
}

